var twoSum = function (nums, target) {
  // 2,4,6,4,3 target=5
  let map = {}
  // nums.forEach((item, idx) => map[item] = idx);

  for (let i = 0; i < nums.length; i++) {
    let lastNum = target - nums[i]
    if (map[lastNum] >= 0) {
      return [map[lastNum], i]
    }
    if (!map[nums[i]]) {
      map[nums[i]] = i
    }
  }
}
let idxs = twoSum([2, 4, 6, 4, 3], 7)
console.log('idxs==', idxs)
